// mark
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 100

void transfrom(char lan[])
{
    char s1[MAX], s2[MAX], s3[MAX];
    int top1, top2, top3;
    top1 = top2 = top3 = -1;
    for (int i = 0; i < strlen(lan); i++)
    {
        s1[++top1] = lan[i];
    }
    while (top1 >= 0)
    {
        char c = s1[top1--];
        if (c != '(')
        {
            s2[++top2] = c;
        }
        else
        {
            while (s2[top2] != ')')
                s3[++top3] = s2[top2--];
            top2--;
            char t = s3[0];
            while (top3 > 0)
            {
                s2[++top2] = t;
                s2[++top2] = s3[top3--];
            }
            s2[++top2] = t;
        }
    }
    while (top2 >= 0)
    {
        char p = s2[top2--];
        switch (p)
        {
        case 'A':
            printf("sae");
            break;
        case 'B':
            printf("tsaedsae");
            break;
        default:
            printf("%c", p);
            break;
        }
    }
}

int main()
{
    /*******************code*******************/
    transfrom("(xy(ab))");
    /******************************************/
    printf("\n\n****************************\n");
    printf("Press Enter key to continue\n");
    getchar();
    return 0;
    /******************************************/
}
